﻿using System;
using System.IO;
using System.Windows.Forms;
using Tilver.Coder.Core;

namespace Tilver.Coder.Win.Views
{
    public partial class ProjectView : UserControl
    {
        private CoderProject _project;
        public CoderProject Project
        {
            get { return _project; }
            set
            {
                _project = value;
                textBoxAuthor.Text = _project.Author;
                textBoxName.Text = _project.Name;
                textBoxNameSpace.Text = _project.NameSpace;
                textBoxSaveDirectory.Text = _project.SaveDirectory;
            }
        }

        public ProjectView()
        {
            InitializeComponent();
            //folderBrowserDialogSaveDirectory.SelectedPath = Directory.GetCurrentDirectory();
        }

        private void buttonSaveDirectory_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialogSaveDirectory.ShowDialog() == DialogResult.OK)
            {
                textBoxSaveDirectory.Text = folderBrowserDialogSaveDirectory.SelectedPath;
            }
        }

        private void buttonSave_Click(object sender, EventArgs e)
        {
            _project.Author = textBoxAuthor.Text;
            _project.Name = textBoxName.Text;
            _project.NameSpace = textBoxNameSpace.Text;
            _project.SaveDirectory = textBoxSaveDirectory.Text;
        }
    }
}
